package service.Bill;

import dao.bill.BillMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.Bill;

import java.util.List;

@Service("billService")
public class BillServiceImpl implements BillService {
    @Autowired
    private BillMapper billMapper;

    public BillMapper getBillMapper() {
        return billMapper;
    }

    public void setBillMapper(BillMapper billMapper) {
        this.billMapper = billMapper;
    }

    public Bill getBillByBillCode(String billCode) {
        try {
            return billMapper.getBillByBillCode(billCode);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    public int getBillCount(String queryProductName, Integer queryProviderId) {
        // TODO Auto-generated method stub
        int count = 0;
        try {
            count=billMapper.getBillCount(queryProductName,queryProviderId);
        }
        catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return count;
    }

    public List<Bill> getBillListByPage(String queryProductName, Integer queryProviderId, Integer currentPageNo, Integer pageSize) {
        // TODO Auto-generated method stub
        List<Bill> billList = null;

        try {
            billList=billMapper.getBillListByPage(queryProductName,queryProviderId,currentPageNo,pageSize);
        }
        catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return billList;
    }
}
